/** * This code is part of the Bumpslide Library by David Knape * http://bumpslide.com/ *  * Copyright (c) 2006, 2007, 2008 by Bumpslide, Inc. *  * Released under the open-source MIT license. * http://www.opensource.org/licenses/mit-license.php * see LICENSE.txt for full license terms */ package app {	import app.data.Config;	import flash.display.DisplayObjectContainer;	/**	 * Controller Initializes Model, and Service Layers	 * 	 * If you want to use commands, make your controller a	 * subclass of FrontController.  This controller is 	 * for apps that just relay on model/state changes	 * as the primary control mechanism, and as such,	 * this is really just a bunch of startup logic.	 * 	 * @author David Knape	 */	public class Controller  	{		private var model:Model = Model.getInstance();		private var service:Service = Service.getInstance();		private var view:DisplayObjectContainer;
		private var _callback:Function;				/**		 * Sets up the model and view for our application		 */		function Controller( appRoot:DisplayObjectContainer, callback:Function ) 		{        				view = appRoot;			_callback = callback;        				// pass flashvars to app configuration in model			model.config = new Config(getFlashVars());							// init services			service = Service.getInstance();			service.rssUrl = model.config.rssUrl;						// let app root know we are ready			// usually we have to wait for some asynchronous process to complete			// but sometimes not, so we use callback instead of events			notifyComplete();		}				private function notifyComplete():void 		{			_callback.call(null);		}
				/**		 * assuming the view is at or near root, should get us flashvars		 */		protected function getFlashVars():Object 		{			return (view.parent != null) ? view.parent.loaderInfo.parameters : view.loaderInfo.parameters; 		}	}}